package io.mft.web.adapter.context;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

import io.mft.dev.base.init.MFTFrameworkInitor.MainHostProgramApplicationContextProvider;
import io.mft.web.adapter.api.WebApiRuningAdapter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MFTApiWebContext implements ApplicationListener<ContextRefreshedEvent>{ 

	

	@Autowired
	private WebApiRuningAdapter webApiRuningAdapter;
	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
		try {
			webApiRuningAdapter.start(new MainHostProgramApplicationContextProvider() {
				
				@Override
				public ApplicationContext provide() {
					return event.getApplicationContext();
				}
			});
			log.info("MFT运行适配启动完成");
		} catch (Throwable e) {
			log.error("MFT执行引擎初始化异常",e);
		}

	}

	/**
	@Override
	protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
		RequestMappingHandlerMapping mapping= new ApiRequestMappingHandlerMapping();
		return mapping;
	}
	
	**/
}
